package com.example.tbtx.tbtx.retrofit;

import android.content.Context;
import android.widget.Toast;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public abstract class NetCallBack<T> implements Callback<T> {
    public Context context;

    public NetCallBack(Context context) {
        this.context = context;
    }

    @Override
    public void onResponse(Call<T> call, Response<T> response) {
        if (response.body()==null) {
            Toast.makeText(context, "数据错误", Toast.LENGTH_SHORT).show();
            return;
        }else {
            onSuccess(call,response);
        }
    }
    @Override
    public void onFailure(Call call, Throwable t) {
        Toast.makeText(context, "数据错误", Toast.LENGTH_SHORT).show();

    }

    public abstract void onSuccess(Call<T> call, Response<T> response);


}
